package it.uniroma2.structure;

public class VariableProcess extends Variable{
	private String namespace;
	private String msgType;
	private String part;
	private String prefix;
	private Process process;
	
	public VariableProcess(String name, String msgType, String part, String namespace, String prefix, Process proc) {
		super(name);
		this.prefix = prefix;
		this.part = part;
		this.namespace = namespace;
		this.msgType = msgType;
		this.process = proc;
	}

	
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	public String getMsgType() {
		return msgType;
	}

	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}

	public String getPart() {
		return part;
	}

	public void setPart(String part) {
		this.part = part;
	}

	
	@Override
	public boolean equals(Object obj) {
		return false;
	}

	@Override
	public String toString() {
		return super.toString() + " messageType=\"" + this.prefix + ":" + this.msgType + "\"";
	}
	
	
	@Override
	public String toBPEL() {
		return "<" + super.variableTag + " " + this.toString() + "/>\n";
	}


	public String getPrefix() {
		return this.prefix;
	}


	public String getHierarchyProcessWSDL() {
		String output = "";
		
		if(this.msgType.substring(this.msgType.length()-8).equals("Response")){
			System.out.println(this.msgType.substring(this.msgType.length()-8));
			String name = this.process.mainNode.getName();
			output = "<impl:" + name + "Response" + " xmlns:impl=\"" + this.process.getTargetNamespace()
					+ "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
			output = output + "<impl:result>impl:result</impl:result>\n";
			output = output + "</impl:" + name + "Response>\n";
		}
		else{
			String name = this.process.mainNode.getName();
			output = "<impl:" + name + "Request" + " xmlns:impl=\"" + this.process.getTargetNamespace()
					+ "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
			output = output + "<impl:input>impl:input</impl:input>\n";
			output = output + "</impl:" + name + "Request>\n";
		}
		
		return output;
	}

}
